/*
 * ImageLoader.java
 * Copyright (C) 2007 Ezequiel Turovetzky
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 3
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, see <http://www.gnu.org/licenses/>.
 */
package ar.com.botonera.gui.common;

import java.awt.Image;
import java.net.URL;

import javax.swing.Icon;
import javax.swing.ImageIcon;

/**
 * Simple clase utilitaria para obtener im&aacute;genes.
 * @author <a href="mailto:tezequiel@gmail.com">Ezequiel Turovetzky</a>
 * @version 1.0
 */
public final class ImageLoader {

    //~ Constructors -----------------------------------------------------------

    /**
     * Constructor privado.
     * <br>Nadie debe instanciar esta clase.
     */
    private ImageLoader() {
    }

    //~ Methods ----------------------------------------------------------------

    /**
     * Carga una imagen a partir de un nombre de archivo.
     * @param file El archivo de imagen (<code>.png</code>, <code>.gif</code>, <code>.jpeg</code>)
     * @return La imagen.
     */
    public static Image loadImage(String file) {
        URL url = ImageLoader.class.getClassLoader().getResource(file);
        return new ImageIcon(url).getImage();
    }

    /**
     * Carga un &iacute;cono a partir de un nombre de archivo.
     * @param file El archivo de imagen (<code>.png</code>, <code>.gif</code>, <code>.jpeg</code>)
     * @return El &iacute;cono.
     */
    public static Icon loadIcon(String file) {
        URL url = ImageLoader.class.getClassLoader().getResource(file);
        return new ImageIcon(url);
    }
}
